home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / fstab / dir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-01  |  495 b   |  26 lines

  1. #include <string.h>
  2. #include <dirent.h>
  3. #include "fstab.h"
  4.  
  5. /*
  6.     Get the list of files (anything in fact) in a directory
  7.     Return the number of entry placed in lst.
  8.  
  9.     Return -1 if the directory can't be opened.
  10. */
  11. int dir_getlist (const char *path, SSTRINGS &lst)
  12. {
  13.     int ret = -1;
  14.     DIR *fin = opendir(path);
  15.     if (fin != NULL){
  16.         struct dirent *dire = NULL;
  17.         while ((dire = readdir(fin))!=NULL){
  18.             lst.add (new SSTRING(dire->d_name));
  19.         }
  20.         closedir(fin);
  21.         ret = lst.getnb();
  22.     }
  23.     return ret;
  24. }
  25.  
  26.